package com.imooc.product.design;

/**
 * Created on 2020/2/3.
 *
 * @author Grak
 * @since 1.0
 */
public class GrayCat {

    private String name;
    private int age;
    private String kind;
    private String descript;

    public GrayCat(GrayCatBuilder catBuilder){
        this.name = catBuilder.name;
        this.age = catBuilder.age;
        this.kind = catBuilder.kind;
        this.descript = catBuilder.descript;
    }

    @Override
    public String toString() {
        return "GrayCat{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", kind='" + kind + '\'' +
                ", descript='" + descript + '\'' +
                '}';
    }

    public static GrayCatBuilder newBuilder(){
        return new GrayCatBuilder();
    }

    public static class GrayCatBuilder{
        private String name;
        private int age;
        private String kind;
        private String descript;

        public GrayCatBuilder setName(String name) {
            this.name = name;
            return this;
        }

        public GrayCatBuilder setAge(int age) {
            this.age = age;
            return this;
        }

        public GrayCatBuilder setKind(String kind) {
            this.kind = kind;
            return this;
        }

        public GrayCatBuilder setDescript(String descript) {
            this.descript = descript;
            return this;
        }

        public GrayCat build(){
            return new GrayCat(this);
        }
    }

    public static void main(String[] args) {
        GrayCat cat = GrayCat
                .newBuilder()
                .setAge(11)
                .setDescript("可爱的灰猫")
                .setKind("猫科")
                .setName("马花花")
                .build();
        System.out.println(cat.toString());
    }
}
